{# Approval cards (#1368): the change queue's confirmation surface, defined once and shown in the chat (a reply carries the cards its tools proposed) and in the review list. The rows are the queue's own description of the change, resolved from the database, never the model's words. Approve and Reject swap the card for its new state. #} {% from "components/macros/form.html" import action, checkbox %} {% from "components/macros/feedback.html" import error_banner %} {% from "components/macros/layout.html" import badge, facts %} {# The frame both cards share: a title line, its right-hand side as the caller's body, then ``rows``. A batch is a form so its "skip" boxes ride along: htmx sends the enclosing form's fields with a button's POST. #} {% macro _card(tag, id, data, title, side, by=none) %} <{{ tag }} id="{{ id }}" {{ data }} class="my-2 border border-aegis-border rounded-lg p-3 text-sm bg-aegis-card">
{{ title }} {{ side }}
{% if by %}
{{ by }}
{% endif %} {{ caller() }} {% endmacro %} {% macro _actions(url, target, reject) %} {% set swap = 'hx-target="#' ~ target ~ '" hx-swap="outerHTML"' %}
{{ action("Approve", 'hx-post="' ~ url ~ '/approve" ' ~ swap, tone="primary") }} {{ action(reject, 'hx-post="' ~ url ~ '/reject" ' ~ swap, tone="danger") }}
{% endmacro %} {% macro change_card(change) %} {% call _card("div", "change-" ~ change.id, "data-change", change.title, badge(change.label, change.tone), change.by) %}
{{ facts(change.display) }}
{% if change.error %}
{{ error_banner([change.error]) }}
{% endif %} {% if change.status == "pending" %}{{ _actions(change.url, "change-" ~ change.id, "Reject") }}{% endif %} {% endcall %} {% endmacro %} {% macro batch_card(batch) %} {% set count = batch.rows|length %} {% call _card("form", "batch-" ~ batch.batch_id, "data-change-batch", batch.title, count ~ (" change" if count == 1 else " changes"), batch.by) %} {% if batch.pending %}{{ _actions(batch.url, "batch-" ~ batch.batch_id, "Reject all") }}{% endif %} {% endcall %} {% endmacro %}